/**
 * android终端
 */
export const isAndroid =
  navigator.userAgent.indexOf('Android') > -1 || navigator.userAgent.indexOf('Adr') > -1

/**
 * ios终端
 */
export const isIOS = !!navigator.userAgent.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/)

/**
 * @param {string} url
 * @returns {Boolean}
 */
export function validURL(url: string) {
  const reg = /^(https?|ftp):\/\/([a-zA-Z0-9.-]+(:[a-zA-Z0-9.&%$-]+)*@)*((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])){3}|([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+\.(com|edu|gov|int|mil|net|org|biz|arpa|info|name|pro|aero|coop|museum|[a-zA-Z]{2}))(:[0-9]+)*(\/($|[a-zA-Z0-9.,?'\\+&%$#=~_-]+))*$/
  return reg.test(url)
}

/**
 * 检测字符串是否全为汉字
 * @param str
 */
export function isAllChineseCharacter(str: string) {
  return /^[\u4e00-\u9fa5]+$/.test(str)
}

/**
 * 检查字符串是否包含汉字
 * @param str
 */
export function isHasChineseCharacter(str: string) {
  return /.*[\u4e00-\u9fa5]+.*/.test(str)
}

/**
 * 是否为整数
 * @param s
 * @returns {*|boolean}
 */
export function isInt(s: string) {
  return /^\d+$/.test(s)
}
